package com.springmvc.controller;

import com.springmvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RequestBodyController {

    @RequestMapping("/requestBody")
    public String requestBody(){
        return "requestBody";
    }

    @RequestMapping("/requestBodyParam1")
    @ResponseBody
    public String requestBodyParam1(@RequestBody(required = true) User user){

        System.out.println("user--->"+user);

        return "success";

    }

    @RequestMapping("/requestBodyParam2")
    @ResponseBody
    public User requestBodyParam2(@RequestBody(required = true) User user){

        System.out.println("user--->"+user);

        return user;

    }

}
